@use 'constants';

.rd-discussion-row {
  --rd-line-border-color: var(--rd-content-border-color);
  --content-border-radius: 0 0 var(--rd-row-bottom-right-radius) var(--rd-row-bottom-left-radius);
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  background-color: var(--gl-background-color-subtle);
  border-radius: var(--content-border-radius);
  border-left: 1px solid var(--rd-line-border-color);
  border-right: 1px solid var(--rd-line-border-color);
  container: discussion-row / inline-size;
}

.rd-discussion-row:has(> td:not(:empty)) {
  border-top: 1px solid var(--rd-line-border-color);
  border-bottom: 1px solid var(--rd-line-border-color);
}

.rd-discussion-row.rd-discussion-row:last-child {
  border-bottom: 0;
}

.rd-discussion-row > td {
  @apply gl-max-w-limited;
  flex: 1;
  min-width: 0;
  padding: 0;
  border-left: 1px solid var(--rd-line-border-color);
  border-right: 1px solid var(--rd-line-border-color);
  border-radius: 0 0 var(--rd-row-bottom-right-radius) var(--rd-row-bottom-left-radius);
}

.rd-discussion-row > td:only-child {
  @container discussion-row (min-width: theme('maxWidth.limited')) {
    border-bottom-right-radius: 0;
  }
}

.rd-discussion-row > td:first-child {
  margin-left: -1px;
}

.rd-discussion-row > td:last-child {
  margin-right: -1px;
}

.rd-discussion-row > td:first-child:not(:only-child),
.rd-discussion-row > td:first-child:empty {
  border-right-color: transparent;
}

.rd-new-discussion-toggle {
  position: absolute;
  left: 0;
  top: 50%;
  padding: 1px;
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translate(-50%, -50%);
  background: var(--gl-background-color-default);
  color: var(--gl-feedback-info-icon-color);
  border: 1px solid var(--gl-feedback-info-icon-color);
  border-radius: 50%;
  z-index: constants.$diff-file-new-discussion-toggle-z-index;

  &:hover,
  &:focus {
    background: var(--gl-feedback-info-icon-color);
    color: var(--gl-background-color-default);
  }

  &::before {
    content: "";
    position: absolute;
    inset: -2px;
  }
}
